﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace Parlez.Utilities
{
    /// <summary>
    /// Provides standard tools
    /// </summary>
    public class Utils
    {
        public string GetCookieValue(string Key)
        {
            HttpCookie _ExistingCookie_HttpCookie = HttpContext.Current.Request.Cookies[Key];

            if (_ExistingCookie_HttpCookie != null)
            {
                return _ExistingCookie_HttpCookie.Value;
            }

            return String.Empty;
        }

        public void SetCookie(string Key, string Value)
        {
            HttpCookie _NewCookie_HttpCookie = HttpContext.Current.Request.Cookies[Key];

            if (_NewCookie_HttpCookie != null)
            {
                _NewCookie_HttpCookie.Value = Value;
                HttpContext.Current.Response.SetCookie(_NewCookie_HttpCookie);
            }
            else
            {
                _NewCookie_HttpCookie = new HttpCookie(Key, Value);
                HttpContext.Current.Response.Cookies.Add(_NewCookie_HttpCookie);
            }
        }
    }
}
